package spring.framework.study.service.seckill;

import java.util.List;

import spring.framework.study.dto.seckill.Exposer;
import spring.framework.study.dto.seckill.SeckillExecution;
import spring.framework.study.entity.seckill.Seckill;
import spring.framework.study.exception.RepeatKillException;
import spring.framework.study.exception.SeckillCloseException;
import spring.framework.study.exception.SeckillException;

/**
 * Created by wchb7 on 16-5-13. 业务接口:站在"使用者"的角度设计接口
 * 1.方法的定义的粒度.2.参数.3.返回类型(return /异常)
 */
public interface ISeckillService {

	/**
	 * 查询所有秒杀记录
	 *
	 * @return
	 */
	List<Seckill> getSeckillList();

	/**
	 * 查询单个秒杀记录
	 *
	 * @param seckillId
	 * @return
	 */
	Seckill getById(Long seckillId);

	/**
	 * 秒杀开启时输出秒杀接口地址 否则输出系统时间和秒杀时间
	 *
	 * @param seckillId
	 * @return
	 */
	Exposer exportSeckillUrl(Long seckillId);

	/**
	 * 执行秒杀操作
	 *
	 * @param seckillId
	 * @param userPhone
	 * @param md5
	 * @return
	 */
	SeckillExecution executeSeckill(Long seckillId, Long userPhone, String md5)
			throws SeckillException, RepeatKillException, SeckillCloseException;

	/**
	 * 执行秒杀操作 by 存储过程
	 *
	 * @param seckillId
	 * @param userPhone
	 * @param md5
	 * @return
	 */
	SeckillExecution executeSeckillProcedure(Long seckillId, Long userPhone, String md5);

}
